insert data to access database c#

66

insert data to access database c# -

string constr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\\your_DataBase_Name.accdb;";
                   OleDbConnection Con = new OleDbConnection(constr);
                   Con.Open();
                   OleDbCommand com = new OleDbCommand();
                   com.Connection = Con;
                   com = new OleDbCommand("your insert command here", Con);
                   int Num=com.ExecuteNonQuery();
                   if (Num != 0)
                   {
                       MessageBox.Show("Record Successfully Added....", "Add Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
                       this.Close();
                   }
                   else
                   {
                       MessageBox.Show("Record is not Added....", "Add Record Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                   }

Comments

Submit
0 Comments